<?php

/*
 * @author Ebrain Cedeno <ebraincedeno@gmail.com>
 */

class TImage extends TWidget{
    
    public $Alt;
    public $IsMap;
    public $Src;
    public $UseMap;
    public $onClick='';
    public $mouseOver ='';
    public $mouseOut = '';
    
    public function __construct() {
        parent::__construct(__CLASS__);
    }
    
    protected function getAlt(){
        
        if ($this->Alt != ""){
            return 'alt="'.$this->Alt.'" ';
        }
        
    }
    
    protected function getUseMap(){
        
        if ($this->UseMap != ""){
            return 'usemap="'.$this->UseMap.'" ';
        }       
    }
    
    protected function OnClick(){
        
        if ($this->onClick != ""){
            return '<script type="text/javascript">
                        $(document).ready(function(){
                        
                            $("#'.$this->Id.'").click(function(event){
                                '.$this->onClick.'
                            });
                        });
                    </script>';
        }
    }
    
    protected function MouseOver(){
        
        if ($this->mouseOver !=""){
            return '<script type="text/javascript">
                        $(document).ready(function(){
                            $("#'.$this->Id.'").mouseover(function(){
                                '.$this->mouseOver.'
                            });
                        });
                    </script>';
        }    
    }
    
    protected function MouseOut(){
        
        if ($this->mouseOut !=""){
            return '<script type="text/javascript">
                        $(document).ready(function(){
                            $("#'.$this->Id.'").mouseout(function(event){
                                '.$this->mouseOut.'
                            });
                        });
                    </script>';
        }
    }

    public function show(){
        
        if ($this->Visible == true){
            
            $html = '<img id="'.$this->Id.'" src="'.$this->Src.'" '.$this->getAlt().' '.$this->getOptionsAditional().' '.$this->getUseMap().'/>'."\n";
            $html .= $this->OnClick();
            $html .= $this->MouseOver();
            $html .= $this->MouseOut();
            
            return $html;
        }
    }
    
}

?>
